<?php
// +----------------------------------------------------------------------
// | 有小象汇 自研正版源码 赋能开发者
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 http://www.uxphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 有小象汇并不是自由软件，未经许可不能去掉有小象汇相关版权
// +----------------------------------------------------------------------
// | Author:  有小象汇
// +----------------------------------------------------------------------

namespace app\adminapi\controller\v1\car;

use app\adminapi\controller\AuthController;
use app\services\car\CarStaffService;
use think\facade\App;

class CarStaff extends AuthController
{
    public function __construct(App $app,CarStaffService $service)
    {
        parent::__construct($app);
        $this->services = $service;
    }

    /**
     * 获取列表
     * @return mixed
     */
    public function getList() {
        $where = $this->request->getMore([
            ['keywords',''],
            ['field_key',''],
            ['place_id',''],
        ]);
        $admin = $this->request->adminInfo();
        if($admin['store_id']) $where['place_id'] = $admin['store_id'];
        $list = $this->services->getList($where,'*','true');
        return app('json')->success($list);
    }

    /**
     * 获取表单
     * @param $id
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function add($id) {
        return app('json')->success($this->services->add((int)$id));
    }

    /**
     * 添加修改保存
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function save() {
      $data = $this->request->postMore([
          ['id',''],
          ['place_id',''],
          ['login_name',''],
          ['pwd',''],
//          ['true_pwd',''],
          ['user_name',''],
          ['user_phone',''],
          ['status','']
      ]);
      return app('json')->success($this->services->save($data));
    }

    /**
     * 审核状态
     */

    /**
     * 删除店员
     */
    public function del($id) {
        return app('json')->success($this->services->del((int)$id));
    }
}
